define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/match_comment/index' + location.search,
                    add_url: 'user/match_comment/add',
                    edit_url: 'user/match_comment/edit',
                    del_url: 'user/match_comment/del',
                    multi_url: 'user/match_comment/multi',
                    import_url: 'user/match_comment/import',
                    table: 'user_match_comment',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'umc_id',
                sortName: 'umc_id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'umc_id', title: __('Umc_id'),visible:false},
                        {field: 'user_id', title: __('User_id'),visible:false},
                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
                        {field: 'm_id', title: __('M_id'),visible:false},
                        {field: 'up_umc_Id', title: __('Up_umc_id'),visible:false},
                        {field: 'ct_date', title: __('Ct_date')},
                        {field: 'up_date', title: __('Up_date')},
                        {field: 'delete', title: __('Delete'), searchList: {"0":__('Delete 0'),"1":__('Delete 1')}, formatter: Table.api.formatter.normal},
                        {field: 'match.name', title: __('Match.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'match.province', title: __('Match.province'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'match.city', title: __('Match.city'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'match.area', title: __('Match.area'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'match.delete', title: __('Match.delete')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
